import sqlite3

conn = sqlite3.connect('../database.db')
conn.row_factory = sqlite3.Row

for i in range(808, 809):
    table_name = 'gate_pass_info_{}'.format(i)
    sql = 'select * from {}'.format(table_name)
    result = conn.execute(sql).fetchall()
    with open('../gate_pass_info/{}'.format(table_name), 'w', encoding='utf8') as f:
        for row in result:
            data = list(row)
            data[4] = str(data[4])
            line = ','.join(data) + '\n'
            f.write(line)
    print('{} finish write'.format(table_name))